const CACHE_DEFAULT_PAT_INFO_KEY = 'defaultPatInfo'
const CACHE_OPENID = 'cacheOpenId'
const CACHE_UNIONID = 'cacheUnionId'
const CACHE_TOKEN_PARAM = 'tokenParam'
const CACHE_TERMINALID = 'terminalId'
const CACHE_SYSTEMINFO = 'systemInfo'
const CACHE_DHCCAM_APPID = 'dhccAppId'
const CACHE_AUTH_TOKEN = 'authToken'
const CACHE_CRYPTO = 'cacheCrypto'
const CACHE_CONFIG = 'cacheConfig'
const CACHE_TEMPLATEID = 'subTemplateId'
const CACHE_MEDDATE = 'medData'
const MS_CLIENT_USERINFO = 'msClientUserInfo'
const CACHE_MEDPATH = 'medpath'
const P_IN_P = 'pictureInPicture'
const CACHE_HOSPITALID = 'hospitalId'
const THEME = 'theme'
const I18N_LOCALE = 'i18n-locale'
const WXCODEURL = 'WxCodeUrl'

function setDefaultPatInfo(patInfo) {
  if (this.getOpenId()) {
    uni.setStorageSync(CACHE_DEFAULT_PAT_INFO_KEY + this.getOpenId(), patInfo)
  }
}

function getDefaultPatInfo() {
  if (this.getOpenId()) {
    return uni.getStorageSync(CACHE_DEFAULT_PAT_INFO_KEY + this.getOpenId())
  }
}

function clearDefaultPatInfo() {
  if (this.getOpenId()) {
    uni.removeStorageSync(CACHE_DEFAULT_PAT_INFO_KEY + this.getOpenId())
  }
}

function setOpenId(openId) {
  uni.setStorageSync(CACHE_OPENID, openId)
}

function getOpenId() {
  return uni.getStorageSync(CACHE_OPENID)
}

function setUnionId(unionId) {
  uni.setStorageSync(CACHE_UNIONID, unionId)
}

function getUnionId() {
  return uni.getStorageSync(CACHE_UNIONID)
}

/**
 * 获取TOKEN参数
 */
function getTokenParam() {
  return uni.getStorageSync(CACHE_TOKEN_PARAM)
}

/**
 * TOKEN参数存入缓存
 */
function setTokenParam(param) {
  uni.setStorageSync(CACHE_TOKEN_PARAM, param)
}

function clearTokenParam() {
  uni.removeStorageSync(CACHE_TOKEN_PARAM)
}

/**
 * terminalId
 */
function setTerminalId(terminalId) {
  uni.setStorageSync(CACHE_TERMINALID, terminalId)
}

function getTerminalId() {
  return uni.getStorageSync(CACHE_TERMINALID)
}

/**
 * 互联网平台appId
 */
function setDhccAppId(dhccAppId) {
  uni.setStorageSync(CACHE_DHCCAM_APPID, dhccAppId)
}

function getDhccAppId() {
  return uni.getStorageSync(CACHE_DHCCAM_APPID)
}

/**
 * 安全token
 */
function setAuthToken(authToken) {
  uni.setStorageSync(CACHE_AUTH_TOKEN, authToken)
}

function getAuthToken() {
  return uni.getStorageSync(CACHE_AUTH_TOKEN)
}

function clearAuthToken() {
  uni.removeStorageSync(CACHE_AUTH_TOKEN)
}
/**
 * 系统数据
 */
function setSystemInfo(info) {
  uni.setStorageSync(CACHE_SYSTEMINFO, info)
}

function getSystemInfo() {
  return uni.getStorageSync(CACHE_SYSTEMINFO)
}

/**
 * 平台加密数据
 */
function setCrypto(data) {
  uni.setStorageSync(CACHE_CRYPTO, data)
}

function getCrypto() {
  return uni.getStorageSync(CACHE_CRYPTO)
}

/**
 * 微站登录用户账号密码等信息
 */
function setMsClientUserInfo(data) {
  uni.setStorageSync(MS_CLIENT_USERINFO, data)
}

function getMsClientUserInfo() {
  return uni.getStorageSync(MS_CLIENT_USERINFO)
}

function clearMsClientUserInfo() {
  uni.removeStorageSync(MS_CLIENT_USERINFO)
}

/**
 * 配置平台：各项小配置
 */
function setConfig(data) {
  uni.setStorageSync(CACHE_CONFIG, data)
}

function getConfig() {
  return uni.getStorageSync(CACHE_CONFIG)
}

/**
 * 订阅消息模板ID
 */
function setMsgTemplateId(data) {
  uni.setStorageSync(CACHE_TEMPLATEID, data)
}

function getMsgTemplateId() {
  return uni.getStorageSync(CACHE_TEMPLATEID)
}
/**
 * 医保授权返回参数
 */
function setMedData(data) {
  uni.setStorageSync(CACHE_MEDDATE, data)
}

function getMedData() {
  return uni.getStorageSync(CACHE_MEDDATE)
}

function clearMedData() {
  uni.removeStorageSync(CACHE_MEDDATE)
}
/**
 * 医保小程序返回跳出地址setMedPath
 */
function setMedPath(data) {
  uni.setStorageSync(CACHE_MEDPATH, data)
}

function getMedPath() {
  return uni.getStorageSync(CACHE_MEDPATH)
}
function clearMedPath() {
  uni.removeStorageSync(CACHE_MEDPATH)
}

function setVideoStatus(data) {
  uni.setStorageSync(P_IN_P, data)
}
function getVideoStatus() {
  return uni.getStorageSync(P_IN_P)
}

function setHospitalId(data) {
  uni.setStorageSync(CACHE_HOSPITALID, data)
}
function getHospitalId() {
  return uni.getStorageSync(CACHE_HOSPITALID)
}

// 主题
function setTheme(data) {
  uni.setStorageSync(THEME, data)
}
function getTheme() {
  return uni.getStorageSync(THEME)
}

// 国际化
function setI18nLocale(data) {
  uni.setStorageSync(I18N_LOCALE, data)
}
function getI18nLocale() {
  return uni.getStorageSync(I18N_LOCALE)
}

// h5首次进入页面的url
function setWxCodeUrl(data) {
  uni.setStorageSync(WXCODEURL, data)
}
function getWxCodeUrl() {
  return uni.getStorageSync(WXCODEURL)
}

export default {
  setOpenId,
  getOpenId,
  setUnionId,
  getUnionId,
  setDefaultPatInfo,
  getDefaultPatInfo,
  clearDefaultPatInfo,
  setTokenParam,
  getTokenParam,
  clearTokenParam,
  getTerminalId,
  setTerminalId,
  getSystemInfo,
  setSystemInfo,
  getCrypto,
  setCrypto,
  getAuthToken,
  setAuthToken,
  clearAuthToken,
  getDhccAppId,
  setDhccAppId,
  setMsClientUserInfo,
  getMsClientUserInfo,
  clearMsClientUserInfo,
  setConfig,
  getConfig,
  setMsgTemplateId,
  getMsgTemplateId,
  setMedData,
  getMedData,
  clearMedData,
  setMedPath,
  getMedPath,
  clearMedPath,
  setVideoStatus,
  getVideoStatus,
  setHospitalId,
  getHospitalId,
  setTheme,
  getTheme,
  setI18nLocale,
  getI18nLocale,
  setWxCodeUrl,
  getWxCodeUrl
}
